/**
 * 
 */
package kr.co.insoft.core.service.comparison.daily.impl;

import java.util.List;

import kr.co.insoft.auth.model.security.User;
import kr.co.insoft.core.model.comparison.daily.DailyEntityModel;
import kr.co.insoft.core.model.comparison.daily.DailyResultEntityModel;
import kr.co.insoft.core.repository.comparison.daily.DailyRepository;
import kr.co.insoft.core.service.comparison.daily.DailyService;
import kr.co.insoft.framework.exceptions.ExceptionCode;
import kr.co.insoft.framework.exceptions.RepositoryException;
import kr.co.insoft.framework.exceptions.ServiceException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

/**
 * @author IN-SOFT Inc. Park Jong Taek(jtpark@in-soft.co.kr)
 * 
 */
@Service
public class DailyServiceImpl implements DailyService {
	
	@Autowired
	DailyRepository dailyRepository;
	
	/*
	 * (non-Javadoc)
	 * 
	 * kr.co.insoft.core.service.setting.template.script.ScriptService#getPagingList
	 */
	@Override
	public List<DailyResultEntityModel> getChartData(DailyEntityModel dailyEntityModel)
			throws ServiceException {
		try {
			Authentication auths = SecurityContextHolder.getContext()
					.getAuthentication();

			dailyEntityModel.setAuth((User) auths.getPrincipal());
			
			return dailyRepository.getChartData(dailyEntityModel);
		} catch (RepositoryException e) {
			throw new ServiceException(ExceptionCode.SERVICE_EXCEPTION, e);
		}
	}
}
